# 练习一
with open ('./9-4.txt','r',encoding='utf-8') as f:
    #将文件内容读取出来    read（）    readlines()     readline()
    result = f.read()
    #调用字符串count方法，传入参数
    print(result.count('Python'))



#练习二
#一个文件对象，只能读取一次
with open ('./9-4.txt','r',encoding='utf-8') as f:
    #通过read方法读取文件内容并打印
    res = f.read()
    print(res)
    #行数
    str_list = res.split('\n')
    #行数累加
    count = 0
    for i in str_list:
        count +=1
    print(f"总行数为：{count}")